import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 晓星航
 * Date: 2023-05-08
 * Time: 19:30
 */
public class TestDemo {
    public static void main(String[] args) {
        int[] array = {1,2,3,4,5,3,4,6,7,8,1,3,10,3,3,3};
        Map<Integer,Integer> map = new HashMap<>();
        for (int x: array) {
            if (map.get(x) == null) {
                map.put(x,1);
            } else {
                int val = map.get(x);
                map.put(x,val + 1);
            }
        }
        for (Map.Entry<Integer,Integer> entry : map.entrySet()) {
            if (entry.getValue() > 1) {
                System.out.println("key " + entry.getKey() + " val: " + entry.getValue());
            }
        }
        System.out.println(map);
    }
    public static void main3(String[] args) {
        int[] array = {1,2,3,4,5,3,4,6,7,8,1,3,10};
        Set<Integer> set = new HashSet<>();
        for (int x:array) {
            if (!set.contains(x)) {
                set.add(x);
            } else {
                System.out.println(x);
                return;
            }
        }
    }
    public static void main2(String[] args) {
        int[] array = {1,2,3,4,5,3,4,6,7,8,1,3,10};
        Set<Integer> set = new HashSet<>();
        for (int x:array) {
            set.add(x);
        }
        System.out.println(set);
    }
    public static void main1(String[] args) {
        HashBuck hashBuck = new HashBuck();
        hashBuck.put(1,11);
        hashBuck.put(2,22);
        hashBuck.put(5,55);
        hashBuck.put(8,88);
        hashBuck.put(9,99);
        Integer val = hashBuck.get(9);
        System.out.println(val);

    }
}
